/*
 * Light.cc
 *
 *  Created on: Jan 8, 2013
 *      Author: Zermingore
 */

#include "Light.hh"

Light::Light()
{
}

Light::Light(Vector color, float intensity, GLuint programID) :
    _color (color),
    _intensity (intensity),
    _programID (programID)
{
}


Light::~Light()
{
}

void Light::on()
{
    // locations
    GLint sampler = glGetUniformLocation(_programID, "gSampler");
    GLint color = glGetUniformLocation(_programID, "gDirectionalLight.Color");
    GLint light = glGetUniformLocation(_programID, "gDirectionalLight.AmbientIntensity");
    if (sampler == -1 || color == -1 || light == -1)
        std::cerr << "Wrong Light Location" << std::endl;

    glUniform1i(sampler, 0);
    glUniform3f(color, _color.x(), _color.y(), _color.z());
    glUniform1f(light, _intensity);
}

// getters - Setters
Vector Light::getColor()
{
  return _color;
}

Vector Light::getDirection()
{
  return _direction;
}

float Light::getIntensity()
{
  return _intensity;
}

void Light::setColor(Vector col)
{
  _color = col;
}

void Light::setDirection(Vector dir)
{
  _direction = dir;
}

void Light::setIntensity(float i)
{
  _intensity = i;
}
